﻿Public Class frmEntryPhotoGeoref

    Dim strNomFichier As String = ""
    Private Url As String
    Dim proprietes As ClsImageProperties
    Dim dateCourante As Date
    Dim strNomFichier2 As String
    Dim result As Boolean

    Private Sub PctPhoto_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PctPhoto.Click
        dateCourante = Date.Now
        'Prendre la photo
        prise_photo()
    End Sub


    Private Sub actualiserGPS()
        If (m_isFormGPSOpen = True) And (m_isGpsInterpreteurOpen = True) Then
            If ((Not IsNothing(oCurrentGpsPosition.longitude)) And (Not IsNothing(oCurrentGpsPosition.latitude)) _
                And (Not IsNothing(oCurrentGpsPosition.dopH)) And (oCurrentGpsPosition.dopH < 50)) Then
                'Affichage
                lblLatitude.Text = oCurrentGpsPosition.roundLatitude.ToString
                lblLongitude.Text = oCurrentGpsPosition.roundLongitude.ToString
                lblAltitude.Text = oCurrentGpsPosition.roundAltitude.ToString
                lblPrécision.Text = oCurrentGpsPosition.roundPrecisionH
                CalculatePrecision(CInt(IIf(IsNothing(oCurrentGpsPosition.dopH), 50, oCurrentGpsPosition.dopH)), preci_cadre.Width, Preci)
            Else
                lblLatitude.Text = Nothing
                lblLongitude.Text = Nothing
                lblAltitude.Text = Nothing
                lblPrécision.Text = Nothing
                CalculatePrecision(50, preci_cadre.Width, Preci)
            End If
        Else
            lblLatitude.Text = Nothing
            lblLongitude.Text = Nothing
            lblAltitude.Text = Nothing
            lblPrécision.Text = Nothing
            CalculatePrecision(50, preci_cadre.Width, Preci)
        End If


    End Sub

    Private Sub frmPhotoGeoref_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
        actualiserGPS()
    End Sub

    Private Sub prise_photo()
        strNomFichier = PrendrePhotoGeoref()
        strNomFichier2 = strNomFichier.Substring(0, strNomFichier.Length - 4)
        Url = geoPictureDossier & strNomFichier2 & "_ref.nsml"
        ' Public Sub New(ByVal ddate As Nullable(Of DateTime), _
        ' ByVal sWptName As String, ByVal dlon As Double?, ByVal dlat As Double?, ByVal dalt As Double?, ByVal ddop As Double?, ByVal daccuracy As Double?, ByVal sWptCom As String, _
        ' ByVal url As String)
        proprietes = New ClsImageProperties(dateCourante, "", oCurrentGpsPosition.roundLongitude, oCurrentGpsPosition.roundLatitude, _
        oCurrentGpsPosition.roundAltitude, oCurrentGpsPosition.roundPrecisionH, "", strNomFichier)
        'result = proprietes.Save(Url)

        oCurrentListImg.AddOneObjectImg(proprietes)

    End Sub

    Private Sub btnMenu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnMenu.Click
        FormMain.Show()
        Me.Hide()
    End Sub

    Private Sub btnDataShow_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDataShow.Click
        frmDataChoix.CreateObservationTable()
        frmDataObsTable.Show()
    End Sub

    Private Sub btnRetour_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRetour.Click
        frmEntryChoixTypeObs.Show()
        Me.Hide()
    End Sub

    Private Sub btnPos_GPS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPos_GPS.Click
        actualiserGPS()
    End Sub

    Private Sub frmPhotoGeoref_GotFocus(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.GotFocus
        actualiserGPS()
    End Sub

    Private Sub btnRetourMenu_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)

    End Sub

    Private Sub CtlLightGPSTrack_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        frmUtilityTracks.Show()
        Me.Hide()
    End Sub
End Class